/* 后端开发服务器 */
const express = require("express");

const app = express();

app.use(express.static("./public"));

app.use(require("cookie-parser")());

app.get("/users", (req, res) => {
  res.send(req.cookies);
});

/*

HTTP/1.1 304 Not Modified
X-Powered-By: Express
Set-Cookie: count=200; Max-Age=20; Path=/; Expires=Fri, 22 Mar 2024 09:06:25 GMT
ETag: W/"9-M+W85Eji31bQtBIgUzmzv5hl1l4"
Date: Fri, 22 Mar 2024 09:06:05 GMT
Connection: keep-alive
Keep-Alive: timeout=5
*/

app.get("/cookie", (req, res) => {
  res.cookie("count", "200", {
    // expires: new Date(+Date.now() + 5000),
    maxAge: 20000,
    httpOnly: true,
  });
  res.send("cookie ok");
});

app.listen(3001, () => {
  console.log("后端开发服务器 http://127.0.0.1:3001");
});
